<?php
/*
* Controller.php
*
* yc@2009-09-1 11:50:47
*/

abstract class Controller {

    //$models='Book,User,System';
    //$hiddenActions='getUser,getBooks';


    public function __construct()
    {
        
    }

    public function __get($member)
    {
        echo 'Error: Class <strong><big>' . get_class($this) . '</big></strong> does not contain a member varibale called <strong><big>' . $member . '</big></strong>';
        debug();
    }

    public function render($vars = null, $template = null, $ret = false)
    {
        global $ENV;
        if (!is_array($vars) && $vars !== null)
            debug('render(): $vars must be an array') && debug();
        !$template && ($template = $ENV['action']);
        if (!$template)
            debug('render(): $template must be set') && debug();
        $folder = str_replace('Controller','',get_class($this));
        $tplFile = $ENV['root'] . '/app/view/' . strtolower($folder) . '/' . $template . '.tpl.php';
        if (!is_file($tplFile))
            debug('render(): template file <strong>' . $tplFile. '</strong> does not exist.') && debug();
        $view = loadLib('Template');
        if ($ret)
            ob_start();
        $view->render($vars, $tplFile);
        if ($ret)
            return ob_get_clean();
        return true;
    }
}
?>
